<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<script src="<%=request.getContextPath()%>/ui/js/jquery.js"></script>
<script src="<%=request.getContextPath()%>/ui/js/jquery.dataTables.min.js"></script>
<script src="<%=request.getContextPath()%>/ui/js/customDataTables.js"></script>
<script language="javascript">
	function addNewThesis() {
		$('#thesisListForm').attr('action', 'viewNewThesis.html');
		$('#thesisListForm').submit();
	}
	function viewExistingThesis(thesisId) {
		$('#thesisId').val(thesisId);
		$('#thesisListForm').attr('action', 'viewExistingThesis.html');
		$('#thesisListForm').submit();
	}
	function viewThesisDetails(thesisId) {
		$('#thesisId').val(thesisId);
		$('#thesisListForm').attr('action', 'viewThesisDetails.html');
		$('#thesisListForm').submit();
	}
	function printThesisList(){
		window.open('printThesisList.html');
	}
</script>
<%@include file="/ui/jsp/includes/header.jspf"%>

<div class="hero-unit secondary_container">
    <div id="table-subject-header">
        View Thesis List
    </div>
        <hr>

    <div class="row-fluid">

        <form:form id="thesisListForm" method="post">
            <div class="addnew_button">
                <c:if test="${roleId==1 || roleId==3}">
                    <input type="button" title="Add New Thesis" value="Add New" class="btn btn-primary" onclick="javascript:addNewThesis()"/>
                    <input type="button" title="Display in a Print-Friendly Format" value="Print" class="btn btn-primary" onclick="javascript:printThesisList()"/>
                </c:if>
            </div>
            <div class="span10">
                <table id='dataTableList' class="table table-striped table-bordered">
                    <thead>
                        <tr>
                            <th width="5%">Action</th>
                            <th>Thesis Title</th>
                            <th width="15%">Milestone</th>
                            <th width="5%">Student First</th>
                            <th width="5%">Student Last</th>
                            <th width="5%">Thesis Advisor First</th>
                            <th width="5%">Thesis Advisor Last</th>
                            <th style="display:none;">Category</th>
                            <th style="display:none;">Committee Member 1</th>
                            <th style="display:none;">Committee Member 2</th>
                            <th style="display:none;">Committee Member 3</th>
                            <th style="display:none;">Committee Member 4</th>
                            <th style="display:none;">Enrolled Date</th>
                            <th style="display:none;">Prospectus Date</th>
                            <th style="display:none;">Defense Date</th>
                        </tr>
                    </thead>

                    <tbody>
                        <c:forEach var="thesis" items="${thesisList}">
                            <tr class="paginationList">
                                <td>
                                	<a href="javascript:viewThesisDetails('${thesis.thesisId}')">
                                	<img src="<%=request.getContextPath()%>/ui/images/view.gif" title="View"/>
                                	</a>
                                	<c:if test="${roleId==1 || (roleId==2 && loginId == thesis.thesisChairId) || roleId==3}">
                                		<a href="javascript:viewExistingThesis('${thesis.thesisId}')">
                                			<img src="<%=request.getContextPath()%>/ui/images/edit.gif" title="Edit"/>
                                		</a>
                                	</c:if>
                                </td>
                                
                                <td>${thesis.title}</td>
                                <td>${thesis.thesisStatusOverviewString}</td>
                                <td>${thesis.student.getFirstName()}</td>
                                <td>${thesis.student.getLastName()}</td>
                                
                           		<td>${thesis.thesisChairFirstName}</td> 
 	                           	<td>${thesis.thesisChairLastName}</td>
						
<%-- 								<td>${thesis.student.getFullName()}</td> --%>
<%-- 								<td>${thesis.thesisChairName}</td>  --%>
					
                                <td style="display:none;">${thesis.category.categoryName}</td>
                                <td style="display:none;">${thesis.committeeMember1Name}</td>
                                <td style="display:none;">${thesis.committeeMember2Name}</td>
                                <td style="display:none;">${thesis.committeeMember3Name}</td>
                                <td style="display:none;">${thesis.committeeMember4Name}</td>
                                <td style="display:none;">${thesis.enrolledDateStr}</td>
                                <td style="display:none;">${thesis.prospectusDateStr}</td>
                                <td style="display:none;">${thesis.defenseDateStr}</td>
                            </tr>
                        </c:forEach>
                    </tbody>

                </table>
                
            	<div class="pagination">
            	</div>
            <input type="hidden" id="thesisId" name="thesisId" value=""/>
            </form:form>

		
        </div>
    </div>
</div>

<%@include file="/ui/jsp/includes/footer.jspf"%>

